import xlrd
# 下载 xlrd  pip install xlrd==1.2.0
def red_exe(data):
    # 打开Excel表
    book = xlrd.open_workbook("../data/"+data+".xlsx")
    # 找到sheet页
    table = book.sheet_by_name("Sheet1")
    # 获取总行数总列数
    row_Num = table.nrows
    col_Num = table.ncols
    s = []
    key = table.row_values(0)
    if row_Num<=1:
        print("没有数据了")
    else:
        j = 1
        for i in range(row_Num-1):
            d = {}
            values = table.row_values(j)
            for x in range(col_Num):
                d[key[x]] = values[x]
            j += 1
            s.append(d)
        return s


def arrayLoc (array1,array2,array3,str1,str2):
    for i in range(len(array1)) :
        for j in range(len(array2)):
            for k in range(len(array3)):
                print(array1[i], end=',')
                print(array2[j], end=',')
                print(array3[k], end=',')
                print(str1, end=',')
                print(str2)




if __name__ == '__main__':
    data1 = "data1"
    print(red_exe(data1))
    data2 = "data2"
    s = red_exe(data2)
    print(s[0]["cityname"])

    # 二维数组
    array1 = ['erporg', 'MBM']
    array2 = ['110100','110101','110102']
    array3 = ['CN', 'IN', 'ID']
    str1 = 'WMWHSE3'
    str2 = 'WHCNF3'
    arrayLoc(array1,array2,array3,str1,str2)
